package com.ck.server.controller.test;

import com.ck.common.constant.AjaxResult;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ck
 * @date 2024/4/15 10:49
 */
@RestController
@RequestMapping("/trace")
@Api(tags = "日志链路追踪测试接口")
@Slf4j
public class LogTraceTestController {

    @GetMapping("/log")
    public AjaxResult logTraceTest(@RequestParam String name){
      log.info("入参 name={}",name);
      testTrace();
      log.info("调用结束 name={}",name);
      return AjaxResult.success();
    }

    /**这里方便测试把业务代码写入Controller中*/
    private void testTrace() {
        log.info("这是一行info日志");
        log.error("这是一行error日志");
        testTrace2();
    }

    private void testTrace2() {
        log.info("这也是一行info日志");
    }
}
